﻿jQuery.fn.jmp3 = function (passedOptions) {
    var options = {
        "playerpath": "/JavaScript/",
        "filepath": "",
        "backcolor": "",
        "forecolor": "ffffff",
        "width": "25",
        "repeat": "no",
        "volume": "50",
        "autoplay": "false",
        "showdownload": "true",
        "showfilename": "true",
        "soundpath": "/JavaScript/5103.mp3"
    };
    if (passedOptions) {
        jQuery.extend(options, passedOptions);
        playerpath = options.playerpath
    };
    var playerpath = options.playerpath;
    return this.each(function () {
        var _container = jQuery(this);

        //if (!_container.is('.container')) return false;
        var filename = options.soundpath;

        var mp3html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';
        mp3html += 'width="' + options.width + '" height="20" ';
        mp3html += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
        mp3html += '<param name="movie" value="' + playerpath + 'singlemp3player.swf?';
        mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
        mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
        mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" />';
        mp3html += '<param name="wmode" value="transparent" />';
        mp3html += '<embed wmode="transparent" width="' + options.width + '" height="20" ';
        mp3html += 'src="' + playerpath + 'singlemp3player.swf?';
        mp3html += 'showDownload=' + options.showdownload + '&file=' + filename + '&autoStart=' + options.autoplay;
        mp3html += '&backColor=' + options.backcolor + '&frontColor=' + options.forecolor;
        mp3html += '&repeatPlay=' + options.repeat + '&songVolume=' + options.volume + '" ';
        mp3html += 'type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        mp3html += '</object>';
        //alert(mp3html);
        _container.prepend(mp3html + "&nbsp;");

        //        if (options.showfilename == "false") {
        //            jQuery(this).html("")
        //        };
        //        if (_container.is('.container')) {
        //            _container.prepend(mp3html + "&nbsp;");
        //        }
    })
};
